<template>
  <div class="home">
    <img alt="Vue logo" src="../assets/logo.png">
    <button @click="handleChangeGlobalState()">更改全局state</button>
  </div>
</template>

<script>
// @ is an alias to /src

export default {
  name: 'HomeView',
  data() {
    return {
      globalState: {}
    }
  },
  mounted() {
    if (this.$globalStateChange) {
      this.$globalStateChange((cur) => {
        console.log('%c --------vue 子应用最新数据----------------', 'font-size: 18px; color: #07FF07', cur);
        this.globalState = cur
      }, true)
    }
  },
  methods: {
    handleChangeGlobalState() {
      this.$setGlobalState({
        ...this.globalState,
        msgBase: 'vue 子应用更新了 global state',
        msgVue: 'vue子应用新增了数据'
      })
    }
  }
}
</script>
